home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / nwlib15.zip / DEMO.ZIP / PROP.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-20  |  6KB  |  194 lines

  1. unit Prop;
  2.  
  3. interface
  4.  
  5. uses
  6.     SysUtils,
  7.     WinTypes,
  8.     WinProcs,
  9.     Classes,
  10.     Graphics,
  11.     Forms,
  12.     Controls,
  13.     Buttons,
  14.     Dialogs,
  15.     Grids,
  16.     StdCtrls,
  17.     ExtCtrls,
  18.     Nwtools,
  19.     Nwlib,
  20.     NwProp;
  21.  
  22. type
  23.   TwinProp = class(TForm)
  24.     listboxPanel: TPanel;
  25.     buttonPanel: TPanel;
  26.     bCancel: TBitBtn;
  27.     bAdd: TBitBtn;
  28.     bEdit: TBitBtn;
  29.     bDelete: TBitBtn;
  30.     objGrid: TStringGrid;
  31.     NWLib1: TNWLib;
  32.     NWTools1: TNWTools;
  33.     bRename: TBitBtn;
  34.     NWProp1: TNWProp;
  35.     procedure FormCreate(Sender: TObject);
  36.     procedure bAddClick(Sender: TObject);
  37.     procedure bRenameClick(Sender: TObject);
  38.     procedure bDeleteClick(Sender: TObject);
  39.     procedure bEditClick(Sender: TObject);
  40.   private
  41.     { Private declarations }
  42.   public
  43.     { Public declarations }
  44.   end;
  45.  
  46. var
  47.   winProp: TwinProp;
  48.  
  49. implementation
  50.  
  51. {$R *.DFM}
  52.  
  53. uses
  54.   objEdit ;
  55.  
  56. procedure TwinProp.FormCreate(Sender: TObject);
  57.   var
  58.     objList : TStringList;
  59.     nloop   : word       ;
  60.     ncursor : TCursor    ;
  61.   begin
  62.     ncursor := screen.cursor ;
  63.     screen.cursor := crHourglass ;
  64.     autoGridLineHeight(objGrid) ;
  65.     try
  66.       { Add Users, Groups, PrintQs and PrintServers to Grid }
  67.       objList := TStringList.create ;
  68.       objGrid.rowCount     := 1 ;
  69.       objGrid.cells[0,0]   := 'Object Name' ;
  70.       objGrid.cells[1,0]   := 'Object Type' ;
  71.       objList := getBinderyList(getPrimaryServerID,nw_user) ;
  72.       objList.sort ;
  73.       for nloop := 1 to objList.count do begin
  74.         objGrid.rowCount := (objGrid.rowCount+1) ;
  75.         objGrid.cells[0,objGrid.rowCount-1] := objList[nloop-1] ;
  76.         objGrid.cells[1,objGrid.rowCount-1] := 'User' ;
  77.       end;
  78.       objList.clear ;
  79.       objList := getBinderyList(getPrimaryServerID,nw_group) ;
  80.       objList.sort ;
  81.       for nloop := 1 to objList.count do begin
  82.         objGrid.rowCount := (objGrid.rowCount+1) ;
  83.         objGrid.cells[0,objGrid.rowCount-1] := objList[nloop-1] ;
  84.         objGrid.cells[1,objGrid.rowCount-1] := 'Group' ;
  85.       end;
  86.       objList.clear ;
  87.       objList := getBinderyList(getPrimaryServerID,nw_printQ) ;
  88.       objList.sort ;
  89.       for nloop := 1 to objList.count do begin
  90.         objGrid.rowCount := (objGrid.rowCount+1) ;
  91.         objGrid.cells[0,objGrid.rowCount-1] := objList[nloop-1] ;
  92.         objGrid.cells[1,objGrid.rowCount-1] := 'Print Queue' ;
  93.       end;
  94.       objList.clear ;
  95.       objList := getBinderyList(getPrimaryServerID,nw_printServer) ;
  96.       objList.sort ;
  97.       for nloop := 1 to objList.count do begin
  98.         objGrid.rowCount := (objGrid.rowCount+1) ;
  99.         objGrid.cells[0,objGrid.rowCount-1] := objList[nloop-1] ;
  100.         objGrid.cells[1,objGrid.rowCount-1] := 'Print Server' ;
  101.       end;
  102.     finally
  103.       if (objGrid.rowCount > 1) then
  104.         objGrid.fixedRows := 1;
  105.       objList.free ;
  106.       screen.cursor := ncursor ;
  107.     end;
  108.   end;
  109.  
  110. procedure TwinProp.bAddClick(Sender: TObject);
  111.   begin
  112.     try
  113.       application.createForm(TWinObjEdit,winObjEdit);
  114.       winObjEdit.objName.text  := ''   ;
  115.       winObjEdit.fullName.text := ''   ;
  116.       winObjEdit.password.text := ''   ;
  117.       winObjEdit.objType.itemIndex := 0 ;
  118.       winObjEdit.caption       := 'Creating New Object' ;
  119.       winObjEdit.creating      := True ;
  120.       winObjEdit.showModal ;
  121.     finally
  122.       winObjEdit.free ;
  123.     end;
  124.   end;
  125.  
  126. procedure TwinProp.bRenameClick(Sender: TObject);
  127.   var
  128.     ctext : string ;
  129.   begin
  130.     ctext := objGrid.cells[0,objGrid.row] ;
  131.     if inputQuery('Renaming Object: ' + ctext ,
  132.                   'Type New Name:',
  133.                   ctext) then
  134.       begin
  135.         if renameObject(getPrimaryServerID,
  136.                         objGrid.cells[0,objGrid.row],
  137.                         ctext,
  138.                         getObjType(0,objGrid.cells[0,objGrid.row])) then
  139.           objGrid.cells[0,objGrid.row] := upperCase(ctext)
  140.         else
  141.           alertBox('Error Renaming Object;;Check Access Rights and Try Again') ;
  142.       end;
  143.   end;
  144.  
  145. procedure TwinProp.bDeleteClick(Sender: TObject);
  146.   var
  147.     ctemp : string ;
  148.   begin
  149.     ctemp := objGrid.cells[0,objGrid.row] ;
  150.     if YesNoBox(ctemp + ';Deleting Object;;Are You Sure?') then
  151.       begin
  152.         if deleteObject(0,ctemp) then
  153.           begin
  154.             objGrid.cells[0,objGrid.row] := '<Deleted>' ;
  155.             objGrid.cells[1,objGrid.row] := '' ;
  156.             okBox(ctemp + ';Object Deleted Successfully') ;
  157.           end
  158.         else
  159.           alertBox(ctemp + ';Error Deleting Object!') ;
  160.       end;
  161.   end;
  162.  
  163. procedure TwinProp.bEditClick(Sender: TObject);
  164.   var
  165.     ctemp : string ;
  166.     ncursor : TCursor ;
  167.   begin
  168.     ncursor := screen.cursor ;
  169.     screen.cursor := crHourglass ;
  170.     ctemp := objGrid.cells[0,objGrid.row] ;
  171.     try
  172.       application.createForm(TWinObjEdit,winObjEdit);
  173.       winObjEdit.objName.text  := ctemp   ;
  174.       winObjEdit.fullName.text := fullName(0,ctemp) ;
  175.       winObjEdit.password.text := ''   ;
  176.       winObjEdit.caption       := 'Modifying Object' ;
  177.       winObjEdit.creating      := False ;
  178.       case getObjType(0,ctemp) of
  179.         nw_user        : winObjEdit.objType.itemIndex := 0 ;
  180.         nw_group       : winObjEdit.objType.itemIndex := 1 ;
  181.         nw_printQ      : winObjEdit.objType.itemIndex := 2 ;
  182.         nw_printServer : winObjEdit.objType.itemIndex := 3 ;
  183.       end;
  184.       { need to set Duration, Read and Write itemIndexes }
  185.       screen.cursor := nCursor ;
  186.       winObjEdit.showModal ;
  187.     finally
  188.       winObjEdit.free ;
  189.       screen.cursor := nCursor ;
  190.     end;
  191.   end;
  192.  
  193. end.
  194.